using System;
using System.Xml;
using System.Collections.Generic;
using System.Text;
using System.IO.Compression;
using System.IO;
using System.Diagnostics;

namespace GoogleNet
{
    /// <summary>
    /// Utility class that allows to write a KML elemento to file or HTTP stream.
    /// </summary>
    public class KmlWriter
    { 
        /// <summary>
        /// Writes the specified KML element to a file.
        /// </summary>
        /// <param name="kmlElement">The KML element.</param>
        /// <param name="outputFileName">Name of the output file.</param>
        /// <param name="ident">if set to <c>true</c> ident the resulting KML.</param>
        public static void Write(IKmlElement kmlElement, string outputFileName, bool ident)
        {
            XmlTextWriter writer = new XmlTextWriter(outputFileName, Encoding.UTF8);
            if (ident)
            {
                writer.Indentation = 4;
                writer.IndentChar = ' ';
                writer.Formatting = Formatting.Indented;
            }
            kmlElement.GenerateKml(writer);
            writer.Close();
        }

    }
}
